﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace httphelper
{
    public partial class Browser : Form
    {
        public Browser()
        {
            InitializeComponent();
        }

        private void btn_go_Click(object sender, EventArgs e)
        {
            wb.Navigate(tb_url.Text);
        }

        private void btn_clickSession_Click(object sender, EventArgs e)
        {
           
        }

        private void btn_execute_Click(object sender, EventArgs e)
        {
            wb.executeScript(tb_script.Text);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            wb.SetJSESSIONID("http://chifan.aliapp.com/", tb_url.Text);
        }

        private void Browser_Load(object sender, EventArgs e)
        {
            wb.SetCookie("https://www.baidu.com", "BAIDUID", "D8614C7D1E3D221B055F24BF6900272D:FG=1;");
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            string password = "1";
            wb.Navigate(@"C:\Users\john\IdeaProjects\test\test.html");
           // new AutoResetEvent(false).WaitOne(1000);
            wb.executeScript("jiami('"+password+"')");
            new Thread(delegate () {
           
            }).Start();

            DG dg = delegate () {
                new AutoResetEvent(false).WaitOne(1000);
                var body = wb.Document.GetElementById("password");
                MessageBox.Show(body.GetAttribute("value").ToString());
            };
            BeginInvoke(dg);
        }
    }
    public delegate void DG();
}
